package cn.xxliang.aiproject.api.response;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author xxliang
 * @date 2025/7/5  18:02
 * @description
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Response<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private String code;
    private String info;
    private T data;

    public static <T> Response<T> success(T data) {
        return Response.<T>builder()
                .code("200")
                .info("success")
                .data(data)
                .build();
    }

    public static <T> Response<T> success() {
        return Response.<T>builder()
                .code("200")
                .info("success")
                .data(null)
                .build();
    }
    public static <T> Response<T> error(T data) {
        return Response.<T>builder()
                .code("500")
                .info("error")
                .data(data)
                .build();
    }
}
